char check(char x) {
    if (x == ')')return '(';
    if (x == ']')return '[';
    if (x == '}')return '{';
    return 0;
}
bool isValid(char* s) {
    // write code here
    if (strlen(s) % 2 != 0) return 0;
    char* Stack;
    int TOP = -1;
    Stack = (char*)malloc(strlen(s) * sizeof(char));
    for (int i = 0; i < strlen(s); i++) {
        if (s[i] == '(' || s[i] == '[' || s[i] == '{') {
            Stack[++TOP] = s[i];
        }
        if (s[i] == ')' || s[i] == ']' || s[i] == '}') {
            if (check(s[i]) == Stack[TOP]) {
                Stack[TOP--] = '\0';
            }
        }
    }
    if (strlen(Stack) != 0) {
        return 0;
    }
    else {
        return 1;
    }
}